package io.github.wppli.domain.posts.model.entity;

import io.github.wppli.domain.posts.model.valobj.PostsStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author li--jiaqiang 2025−03−11
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PublishPostsEntity {
    /**
     * 帖子ID
     */
    private Long id;
    /**
     * 用户ID
     */
    private Long authorId;

    /**
     * 用户名
     */
    private String authorName;

    /**
     * 用户头像
     */
    private String authorAvatar;

    /**
     * 照片数组
     */
    private List<String> images;

    /**
     * 帖子标题
     */
    private String title;

    /**
     * 正文
     */
    private String content;

    /**
     * '可见范围（0-私有 1-公开）'
     */
    private Integer isPublic;

    /**
     * 状态 - 暂时不审核
     */
    private PostsStatus postsStatus = PostsStatus.NORMAL;

    public String joinImagesWithComma() {
        if (this.images == null || this.images.isEmpty()) {
            return "";
        }
        return String.join(",", images);
    }
}